/*
 * @Author: wangyuan
 * @Date: 2025-04-11 10:22:09
 * @LastEditors: wangyuan
 * @LastEditTime: 2025-04-11 13:20:13
 * @Description: 请填写简介
 * 仅限内部使用
 */
import { defineConfig } from "vite";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import vue from "@vitejs/plugin-vue";

// https://vite.dev/config/
export default defineConfig({
  build: {
    rollupOptions: {
      output: {
        // 排除所有图片文件
        exclude: ["**/*.png", "**/*.jpg", "**/*.jpeg", "**/*.gif", "**/*.svg"],
      },
    },
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    extensions: [".js", ".ts", ".json", ".tsx"],
    alias: {
      "@": "/src",
    }, // 在这里使用 alias
  },
  css: {
    // css预处理器
  },
  server: {
    // 代理配置
    // http://192.168.0.4:8079/
    proxy: {
      "/api": {
        target: "http://192.168.0.4:8079/",
        // target: "http://192.168.0.4:8079/", // 目标服务器地址
        // target: "http://23.24.203.149:8079/", // 生产环境地址
        changeOrigin: true, // 是否改变源
        // rewrite: (path) => path.replace(/^\/api/, ""), // 重写路径，去除/api
      },
      // 可以添加更多代理规则
    },
  },
});
